﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//
using iPublic;

namespace HRecycle.SysTools
{
    /// <summary>
    /// 开回收箱门，海宏软件
    /// 修改记录：
    ///   20180104,zch,创建基本功能
    /// </summary>
    public partial class FrmOpenBack : Form
    {
        public static string sVipID = "";
        private string sDefaultUrl = "http://h.sdzgwl.cn/webapi.php/wxlogin/index";
        public string sDefaultText = "";

        public FrmOpenBack()
        {
            InitializeComponent();
        }

        private void FrmOpenBack_Load(object sender, EventArgs e)
        {
            try
            {
                showInfo("★★进入开回收箱输入单元★★");
                //界面
                FormBorderStyle = FormBorderStyle.None;
                WindowState = FormWindowState.Maximized;
                //
                pl_bottom2.Dock = DockStyle.Bottom;
                lbl_machineID.Text = iDefine.SysConfig.machineID;
                pl_main.Dock = DockStyle.Fill;
                //wb_main.Dock = DockStyle.Fill;
                //
                sDefaultText = txt_vip.Text;
                //txt_vip.Focus();
                //txt_vip.SelectedText = sDefaultText;
                tm_runonce.Enabled = true;
            }
            catch (Exception x)
            { showInfo(x.Message); }
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            if (txt_vip.Text == "") { txt_vip.Focus(); return; }
            Close();
            DialogResult = DialogResult.OK;
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            Close();
            DialogResult = DialogResult.Cancel;
        }

        public void showInfo(string sInfo, bool lTime = true)
        {
            lbl_info.Text = sInfo;
            iLog.writeLogFile(sInfo);
        }

        private void tm_runonce_Tick(object sender, EventArgs e)
        {
            tm_runonce.Enabled = false;
        }

        private void tm_main_Tick(object sender, EventArgs e)
        {
            Timer tm = sender as Timer;
            bool lEnable = tm.Enabled;
            tm.Enabled = false;
            //
            int nTime = Convert.ToInt16(lbl_time.Text) - 1;
            lbl_time.Text = nTime.ToString();
            if (nTime <= 0) btn_cancel_Click(sender, e); else tm.Enabled = lEnable;
        }

        private void FrmOpenBack_Shown(object sender, EventArgs e)
        {
            tm_main.Tag = Convert.ToInt16(lbl_time.Text);
            tm_main.Enabled = true;
            tm_task.Enabled = true;
        }
    }

}
